package cn.sumpu.app.guoguojie.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.sumpu.app.guoguojie.dao.CodeDao;
import cn.sumpu.app.guoguojie.domain.Code;
import cn.sumpu.app.guoguojie.exception.AppBusinessException;

public class CodeDaoImpl extends SqlSessionDaoSupport implements CodeDao {

	private final static Logger logger = LoggerFactory
			.getLogger(CodeDaoImpl.class);

	@SuppressWarnings("unchecked")
	@Override
	public List<Code> getCodeList(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return getSqlSession()
					.selectList(
							"cn.sumpu.app.guoguojie.persistence.CodeMapper.getCodeList",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("query database failure.", e);
			}
			throw new AppBusinessException("query database failure.", e);
		}
	}

}
